﻿<%@ Page Title="" Language="C#" MasterPageFile="~/SurveySystem.Master" AutoEventWireup="true"
    CodeBehind="DetailedGroupView.aspx.cs" Inherits="SurveySystem.Web.DetailedGroupView" %>

<asp:Content ID="Content1" ContentPlaceHolderID="head" runat="server">
    Csoport
</asp:Content>
<asp:Content ID="Content2" ContentPlaceHolderID="contentPlaceholder" runat="server">
    <asp:ScriptManager ID="ScriptManager1" runat="server">
    </asp:ScriptManager>
    <h2>
        <asp:Label ID="lblHead" runat="server" Text=""></asp:Label></h2>
    <h3>
        Felhasználók:</h3>
    <asp:GridView ID="GridView_Members" runat="server" AutoGenerateColumns="False" DataSourceID="membersSource"
        AllowPaging="True" PageSize="5" DataKeyNames="userId, groupId" OnRowCommand="GridView_Members_RowCommand">
        <Columns>
            <asp:TemplateField HeaderText="Nicknév">
                <ItemTemplate>
                    <asp:Label runat="server" Text='<%# ((SurveySystem.Core.Member)Container.DataItem).User.name %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Teljes név">
                <ItemTemplate>
                    <asp:Label runat="server" Text='<%# ((SurveySystem.Core.Member)Container.DataItem).User.fullName %>'>
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Szerep">
                <ItemTemplate>
                    <asp:Label runat="server" Text="<%# SurveySystem.Web.WebUtils.GetRoleString( ((SurveySystem.Core.Member)Container.DataItem).role ) %>">
                    </asp:Label>
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField>
                <HeaderTemplate>
                    Törlés</HeaderTemplate>
                <ItemTemplate>
                    <asp:LinkButton runat="server" Visible="<%# CanDelete(Container.DataItem) %>" CommandName="DeleteUser"
                        CommandArgument="<%# Container.DataItemIndex %>" Text="Törlés" />
                </ItemTemplate>
            </asp:TemplateField>
            <asp:TemplateField HeaderText="Admin jog">
                <ItemTemplate>
                    <asp:LinkButton runat="server" Visible="<%# CanGrantAdminship(Container.DataItem) %>"
                        CommandName="GrantAdminship" CommandArgument="<%# Container.DataItemIndex %>"
                        Text="+" />
                    <asp:LinkButton ID="LinkButton1" runat="server" Visible="<%# CanTakeAdminship(Container.DataItem) %>"
                        CommandName="TakeAdminship" CommandArgument="<%# Container.DataItemIndex %>"
                        Text="-" />
                </ItemTemplate>
            </asp:TemplateField>
        </Columns>
    </asp:GridView>
    <asp:ObjectDataSource ID="membersSource" runat="server" OnSelecting="membersSource_Selecting"
        TypeName="SurveySystem.Core.GroupsBLL" EnablePaging="true" SelectMethod="ListMembersPaged"
        SelectCountMethod="ListMembersCount">
        <SelectParameters>
            <asp:QueryStringParameter Name="groupId" QueryStringField="groupId" Type="Int32" />
        </SelectParameters>
    </asp:ObjectDataSource>
    <asp:Panel ID="requestsPanel" runat="server">
        <h3>
            Csatlakozási kérelmek</h3>
        <asp:GridView ID="GridView_Requests" runat="server" AutoGenerateColumns="False" DataKeyNames="id"
            DataSourceID="requestsDataSource" OnRowCommand="GridView_Requests_RowCommand">
            <Columns>
                <asp:BoundField DataField="name" HeaderText="Nicknév" SortExpression="name" />
                <asp:BoundField DataField="fullName" HeaderText="Teljes név" SortExpression="fullName" />
                <asp:ButtonField CommandName="AcceptRequest" Text="Elfogad" />
                <asp:ButtonField CommandName="DenyRequest" Text="Elutasít" />
            </Columns>
        </asp:GridView>
        <br />
        <asp:Label ID="lblInfo" runat="server"></asp:Label>
        <asp:ObjectDataSource ID="requestsDataSource" runat="server" SelectMethod="ListJoiningRequests"
            TypeName="SurveySystem.Core.GroupsBLL">
            <SelectParameters>
                <asp:QueryStringParameter Name="groupId" QueryStringField="groupId" Type="Int32" />
            </SelectParameters>
        </asp:ObjectDataSource>
    </asp:Panel>
    <asp:UpdatePanel ID="UpdatePanel_ExitGroup" runat="server">
        <ContentTemplate>
            <asp:MultiView ID="exitGroupMultiView" runat="server" ActiveViewIndex="0">
                <asp:View runat="server" ID="exitGroupView0">
                    <asp:HyperLink ID="HyperLink_Return" runat="server" 
                        NavigateUrl="~/MyGroups.aspx">Vissza</asp:HyperLink>
                    &nbsp;
                    <asp:LinkButton ID="btnExitGroup" runat="server" OnClick="btnExitGroup_Click">Kilépés a csoportból</asp:LinkButton>
                </asp:View>
                <asp:View runat="server" ID="exitGroupView1">
                    Előbb ruházd át az owner jogot egy adminnak az alábbiakból:
                    <br />
                    <asp:DropDownList ID="DropDownList_SelectNewOwner" runat="server" 
                        DataSourceID="listAdminsDataSource" DataTextField="name" DataValueField="id">
                    </asp:DropDownList>
                    <asp:ObjectDataSource ID="listAdminsDataSource" runat="server" 
                        SelectMethod="ListAdmins" TypeName="SurveySystem.Core.GroupsBLL">
                        <SelectParameters>
                            <asp:QueryStringParameter Name="groupId" QueryStringField="groupId" 
                                Type="Int32" />
                        </SelectParameters>
                    </asp:ObjectDataSource>
                    <br />
                    <asp:Button ID="btnCancelExit1" runat="server" Text="Mégsem" OnClick="btnCancelExit1_Click" />
                    &nbsp;
                    <asp:Button ID="btnSelectNewOwnerAndExit" runat="server" 
                        Text="Új tulajdonos kiválasztása és kilépés" 
                        onclick="btnSelectNewOwnerAndExit_Click" />
                </asp:View>
                <asp:View runat="server" ID="exitGroupView2">
                    Biztos kilépsz?
                    <br />
                    <asp:Button ID="btnExit" runat="server" Text="Igen" OnClick="btnExit_Click" />
                    &nbsp;
                    <asp:Button ID="btnCancelExit2" runat="server" Text="Mégsem" OnClick="btnCancelExit2_Click" />
                </asp:View>
            </asp:MultiView>
        </ContentTemplate>
    </asp:UpdatePanel>
    <asp:UpdateProgress ID="UpdateProgress1" runat="server">
        <ProgressTemplate>
            Oké ...
        </ProgressTemplate>
    </asp:UpdateProgress>
</asp:Content>
